package com.qf.test;

import com.qf.util.Zkutil;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.data.Stat;
import org.junit.Test;

import java.util.List;

public class testZk {
    private CuratorFramework cf= Zkutil.getCf();

    @Test
    public void test1() throws Exception{
        cf.create().withMode(CreateMode.PERSISTENT).forPath("/qf","sasd".getBytes());
    }

    @Test
    public void test2() throws Exception{
        cf.setData().forPath("/qf","zzzzzzz".getBytes());
    }

    @Test
    public void test3() throws Exception{
        byte[] bytes = cf.getData().forPath("/qf");
        System.out.println("============="+new String(bytes));
    }

    @Test
    public void test4() throws Exception{
        List<String> list = cf.getChildren().forPath("/");
        if (list!=null){
            for (String str : list) {
                System.out.println("============="+str);
            }
        }
    }

    @Test
    public void test5() throws Exception{
        cf.delete().deletingChildrenIfNeeded().forPath("/qf");
    }

    @Test
    public void test6() throws Exception{
        Stat stat = cf.checkExists().forPath("/qf");
        System.out.println("============"+stat);
    }
}
